<?php
class Default_Form_ValidateContact{
	//CHUA NHUNG THONG BAO LOI CUA FORM
	protected $_messagesError = null;
	//MANG CHUA DU LIEU SAU KHI KIEM TRA
	protected $_arrData;
	
	public function __construct($arrParam = array(),$options = null){
		$validator = new Zend_Validate();
		$validator->addValidator(new Zend_Validate_NotEmpty(),true)
				  ->addValidator(new Zend_Validate_EmailAddress(),true);
		if(!$validator->isValid($arrParam['email'])){
			$message = $validator->getMessages();
			$this->_messagesError['email'] = current($message);
		}		
		
		$validator = new Zend_Validate();
		$validator->addValidator(new Zend_Validate_NotEmpty(),true)
				  ->addValidator(new Zendvn_Validate_Captcha($arrParam['captchaID']),true);
		if(!$validator->isValid($arrParam['captcha'])){
			$message = $validator->getMessages();
			$this->_messagesError['captcha'] = current($message);
		}
		

		$validator = new Zend_Validate();
		$validator->addValidator(new Zend_Validate_NotEmpty(),true)
				  ->addValidator(new Zend_Validate_StringLength(5, 100));
		if(!$validator->isValid($arrParam['full_name'])){
			$message = $validator->getMessages();
			$this->_messagesError['full_name'] = current($message);
		}
		
		$validator = new Zend_Validate();
		$validator->addValidator(new Zend_Validate_NotEmpty(),true)
				  ->addValidator(new Zend_Validate_StringLength(10, 200));
		if(!$validator->isValid($arrParam['title'])){
			$message = $validator->getMessages();
			$this->_messagesError['title'] = current($message);
		}

		$validator = new Zend_Validate();
		$validator->addValidator(new Zend_Validate_NotEmpty(),true)
				  ->addValidator(new Zend_Validate_StringLength(15));
		if(!$validator->isValid($arrParam['content'])){
			$message = $validator->getMessages();
			$this->_messagesError['content'] = current($message);
		}

		$this->_arrData = $arrParam;

	}

	public function isError(){	
		if(count($this->_messagesError)>0){
			return true;
		}else{
			return false;
		}
	}

	public function getMessageError(){
		return $this->_messagesError;
	}

	public function getData($options = null){
		return $this->_arrData;
	}
}